﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBHelper;
using BusinessLayer.WorldArtPrice.Entities;
using System.Data.SqlClient;
using System.Data;

namespace BusinessLayer.WorldArtPrice
{
    public class ImageWhatWeDoBL
    {
        private readonly DbHelper _db;

        public ImageWhatWeDoBL()
        {
            _db = new DbHelper(new DbConfig().DbWorldArtPriceConnectionString);         
        }

        public void Insert(ImageWhatWeDo imageWhatWeDo)
        {
            var oCommand = new SqlCommand("sp_ImageWhatWeDo_Insert") { CommandType = CommandType.StoredProcedure };
            oCommand.Parameters.Add(new SqlParameter("@ImageArtist", imageWhatWeDo.ImageArtist));
            oCommand.Parameters.Add(new SqlParameter("@ImageArtistUrl", imageWhatWeDo.ImageArtistUrl));
            oCommand.Parameters.Add(new SqlParameter("@RedirectUrlArtist", imageWhatWeDo.RedirectUrlArtist));
            oCommand.Parameters.Add(new SqlParameter("@ImageArtPrice", imageWhatWeDo.ImageArtPrice));
            oCommand.Parameters.Add(new SqlParameter("@ImageArtPriceUrl", imageWhatWeDo.ImageArtPriceUrl));
            oCommand.Parameters.Add(new SqlParameter("@RedirectUrlArtPrice", imageWhatWeDo.RedirectUrlArtPrice));
            oCommand.Parameters.Add(new SqlParameter("@ImageAuctionCalendar", imageWhatWeDo.ImageAuctionCalendar));
            oCommand.Parameters.Add(new SqlParameter("@ImageAuctionCalendarUrl", imageWhatWeDo.ImageAuctionCalendarUrl));
            oCommand.Parameters.Add(new SqlParameter("@RedirectUrlAuctionCalendar", imageWhatWeDo.RedirectUrlAuctionCalendar));
            _db.ExecuteNonQuery(oCommand);            
        }

        public ImageWhatWeDo GetTop()
        {
            var oCommand = new SqlCommand("sp_ImageWhatWeDo_Select_Top") { CommandType = CommandType.StoredProcedure };
            return _db.GetList<ImageWhatWeDo>(oCommand).FirstOrDefault();
        }
    }
}
